package com.hancai.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hancai.constant.Constants;
import com.hancai.mapper.TActivityMapper;
import com.hancai.model.TActivity;
import com.hancai.query.ActivityQuery;
import com.hancai.query.BaseQuery;
import com.hancai.service.ActivityService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 涵菜
 * @version 1.0
 */
@Service
public class ActivityServiceImpl implements ActivityService {
    @Resource
    private TActivityMapper tActivityMapper;

    @Override
    public PageInfo<TActivity> getActivityByPage(Integer current, ActivityQuery activityQuery) {
        //1,设置PageHelper
        PageHelper.startPage(current, Constants.PAGE_SIZE);
        //2,查询
        List<TActivity>list=tActivityMapper.selectActivityByPage(activityQuery);
        //3，封装分页数据到PageInfo
        PageInfo<TActivity>info=new PageInfo<>(list);
        return info;
    }

    @Override
    public TActivity getActivityById(Integer id) {
        return tActivityMapper.selectDetailByPrimaryKey(id);
    }
}
